<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateProblemStepCategoryTable extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('task_work_order_problem_step_category', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '工单问题环节']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '工单问题环节ID'])
            ->addColumn('task_work_order_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '工单ID'])
            ->addColumn('step_category_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '环节ID'])
            ->addColumn('project_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '项目id'])
            ->addColumn('is_confirm', 'enum', ['values' => 'default,yes,no', 'default' => 'default', 'null' => false, 'comment' => '是否确认(default 未处理,yes 是,no 否)'])
            ->addColumn('plan_end_time', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '解决时间'])
            ->addColumn('confirm_person', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '确认人'])
            ->addColumn('uuid', 'char', ['default' => '', 'limit' => 36, 'comment' => '全局唯一标识符'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建人'])
            ->addColumn('created', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addIndex(['task_work_order_id'], ['type' => 'normal', 'name' => 'idx_task_work_order_id']);
        $table->create();
    }

    public function down()
    {
        $this->table('task_work_order_problem_step_category')->drop()->save();
    }
}
